package com.shop2cn.iapi.promotion.serivce;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;



import com.google.gson.reflect.TypeToken;
import com.shop2cn.iapi.promotion.parameter.GetMultiProductPromotionPolicyReq;
import com.shop2cn.iapi.promotion.parameter.GetMultiProductPromotionPolicyResp;
import com.shop2cn.iapi.promotion.parameter.GetPromotionPolicyByIdReq;
import com.shop2cn.iapi.promotion.parameter.GetPromotionPolicyByIdResp;
import com.shop2cn.iapi.promotion.parameter.ProductDto;
import com.shop2cn.iapi.promotion.parameter.SellerProductDto;
import com.shop2cn.iapi.promotion.parameter.ShoppingCartCalculateReq;
import com.shop2cn.iapi.promotion.parameter.ShoppingCartCalculateResp;
import com.shop2cn.iapi.sellerpromotion.parameter.ConflictProduct;
import com.shop2cn.iapi.sellerpromotion.parameter.CreatePromotionBean;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.Shop2cnSellerPromotionCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
/**
*获取冲突商品列表
*FreeMaker Template自动生成代码
*/
public class GetPromotionByIdCall extends YmatouBaseCall{
	private static String opurl ="api/promotion/GetPromotionById";
	
	public GetPromotionByIdCall() {
		super(EnvSetup.getSystemUrl("promotion_shop2cn_iapi"),opurl,"GET","PARAM");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	public String getCode() {
		return getString("Code");
	}
	public GetPromotionPolicyByIdResp getData() {
		GetPromotionPolicyByIdResp data = null;
        try {
        	String data2=getJsonObject().get("Data").getAsJsonObject().toString();
        	data=(GetPromotionPolicyByIdResp) FormatUtil.GSONToObject(data2, new TypeToken<GetPromotionPolicyByIdResp>() {}.getType());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return data;
	}
	public static void main(String [] args) throws Exception {
		Integer mchId = GodmchManageCallService.CreateSellerMch();
//		AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
//		//商品币种要和活动一致？
//		addAgentProductBean.setCurrency("CNY");
//        String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
		 String pid =TestDataManager.getRandomUUID().toString();
		CreatePromotionBean createpromotionBean = Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 4);
		createpromotionBean.setProductIdList(Arrays.asList(pid));
		Integer promotionId = Shop2cnSellerPromotionCallService.CreatepromotionCall(createpromotionBean);
		
		GetPromotionByIdCall GetPromotionByIdCall=new GetPromotionByIdCall();
		GetPromotionPolicyByIdReq GetPromotionPolicyByIdReq=new GetPromotionPolicyByIdReq();
		GetPromotionPolicyByIdReq.setPromotionId(promotionId);
		GetPromotionPolicyByIdReq.setSellerId(mchId);
		GetPromotionPolicyByIdReq.setShowProduct(true);
		GetPromotionByIdCall.setData(GetPromotionPolicyByIdReq);
		GetPromotionByIdCall.callService();
		Logger.debug("data:"+FormatUtil.beanToGSONString(GetPromotionByIdCall.getData()));
	}
}